<html>
<head>
<title>管理系统</title>
<meta http-equiv=Content-Type content=text/html;charset=utf-8>
<#include "../inc/commonJs.html">
<script type="text/JavaScript">
	var grid;
	var grid1;
	var grid2;
	$(function() {
		 //分类管理表格  
 		 grid = $('#mydocgrid').datagrid({
         url:'listDoc.do',  
         loadMsg:'数据加载中请稍后……',  
         pagination: true,  
         rownumbers: true,
         pageSize: [${syscfg.pageSize!10}],
         pageList: [${syscfg.pageList!10}],
         striped: true,  
         singleSelect : true,  
         columns:[[  
             {field:'docid',title: 'ID',align: 'center',width: '50'},  
             {field:'name',title: '名称',align: 'center',width: '250'},
             {field:'docClassName',title: '类别',align: 'center',width: '100'},
             {field:'userName',title: '上传人',align: 'center',width: '100'},
             {field:'deptName',title: '所属部门',align: 'center',width: '100'},
             {field:'dt',title: '上传时间',align: 'center',width: '150'},
             {field:'zt',title: '状态',align: 'center',width: '150',
             	formatter: function(value,rowdata,index){
             		var str = '';
             		if(value == '0'){
             			str = "不共享";
             		}else if(value == '1'){
             			str = "完全共享";
             		}else if(value == '2'){
             			str = "部门共享";
             		}
					return str;
				}
             },
             {field:'action',title: '操作',align: 'center',width: '150',
             	formatter: function(value,rowdata,index){
             		var str = '';
					str += '<a id="btnadd" class="l-btn l-btn-plain" target="_blank" href="docDownLoad.do?docid='+rowdata.docid+'"><span class="l-btn-left"><span class="l-btn-text icon-redo l-btn-icon-left" >下载</span></span></a>';
					return str;
				}
             }]],
             toolbar : '#mydocgridtoolbar'
     });
     
     grid1 = $('#orgdocgrid').datagrid({
		 width: 'auto',  
         height:'auto',             
         striped: true,  
         singleSelect : true,  
         url:'listDoc.do',  
         loadMsg:'数据加载中请稍后……',  
         pagination: true,  
         rownumbers: true,
         queryParams: {
			zt: '1'
		 },
         columns:[[  
             {field:'docid',title: 'ID',align: 'center',width: '50'},  
             {field:'name',title: '名称',align: 'center',width: '250'},
             {field:'docClassName',title: '类别',align: 'center',width: '100'},
             {field:'userName',title: '上传人',align: 'center',width: '100'},
             {field:'deptName',title: '所属部门',align: 'center',width: '100'},
             {field:'dt',title: '上传时间',align: 'center',width: '150'},
             {field:'zt',title: '状态',align: 'center',width: '150',
             	formatter: function(value,rowdata,index){
             		var str = '';
             		if(value == '0'){
             			str = "不共享";
             		}else if(value == '1'){
             			str = "部门共享";
             		}else if(value == '2'){
             			str = "公司共享";
             		}
					return str;
				}
             },
             {field:'action',title: '操作',align: 'center',width: '150',
             	formatter: function(value,rowdata,index){
             		var str = '';
					str += '<a id="btnadd" class="l-btn l-btn-plain" target="_blank" href="docDownLoad.do?docid='+rowdata.docid+'"><span class="l-btn-left"><span class="l-btn-text icon-redo l-btn-icon-left" >下载</span></span></a>';
					return str;
				}
             }]],
             toolbar : '#orgdocgridtoolbar'
     });
     
     grid2 = $('#alldocgrid').datagrid({
		 width: 'auto',  
         height:'auto',             
         striped: true,  
         singleSelect : true,  
         url:'listDoc.do',  
         loadMsg:'数据加载中请稍后……',  
         pagination: true,  
         rownumbers: true, 
         queryParams: {
			zt: '2'
		 },
         columns:[[  
             {field:'docid',title: 'ID',align: 'center',width: '50'},  
             {field:'name',title: '名称',align: 'center',width: '250'},
             {field:'docClassName',title: '类别',align: 'center',width: '100'},
             {field:'userName',title: '上传人',align: 'center',width: '100'},
             {field:'deptName',title: '所属部门',align: 'center',width: '100'},
             {field:'dt',title: '上传时间',align: 'center',width: '150'},
             {field:'zt',title: '状态',align: 'center',width: '150',
             	formatter: function(value,rowdata,index){
             		var str = '';
             		if(value == '0'){
             			str = "不共享";
             		}else if(value == '1'){
             			str = "部门共享";
             		}else if(value == '2'){
             			str = "公司共享";
             		}
					return str;
				}
             },
             {field:'action',title: '操作',align: 'center',width: '150',
             	formatter: function(value,rowdata,index){
             		var str = '';
					str += '<a id="btnadd" class="l-btn l-btn-plain" target="_blank" href="docDownLoad.do?docid='+rowdata.docid+'"><span class="l-btn-left"><span class="l-btn-text icon-redo l-btn-icon-left" >下载</span></span></a>';
					return str;
				}
             }]],
             toolbar : '#alldocgridtoolbar'
     });
  })
	function addDoc(gridId) {
		var modalwindow = window.top.modalwindow('${request.contextPath}/xadmin/work/docWindow.do',$('#'+gridId),{    
		    width:650,    
		    height:250,
		    modal:true,
		    resizable:true,
		    title:'新增文档信息',
		    buttons:[{
				text:'保存',
				iconCls:"icon-save",
				handler:function(){
					modalwindow.find('iframe').get(0).contentWindow.saveObj('');
				}
			},{
				text:'关闭',
				iconCls:"icon-cancel",
				handler:function(){
					modalwindow.dialog('close');
				}
			}]   
		});
	};
	
	function editDoc(gridId) {
		var selected = $('#'+gridId).datagrid('getSelected');
		if(!selected){
			window.top.$.messager.alert('提示',"请选择相关数据进行操作！");
			return;
		}
		var modalwindow =  window.top.modalwindow('${request.contextPath}/xadmin/work/docWindow.do?docid='+selected.docid,$('#'+gridId),{    
		    width:650,    
		    height:250,
		    modal:true,
		    resizable:true,
		    title:'修改文档信息',
		    buttons:[{
				text:'保存',
				iconCls:"icon-save",
				handler:function(){
					modalwindow.find('iframe').get(0).contentWindow.saveObj(selected.docid);
				}
			},{
				text:'关闭',
				iconCls:"icon-cancel",
				handler:function(){
					modalwindow.dialog('close');
				}
			}]   
		});
	};
	
	//工具栏删除
	function delDoc(gridId){
		var selected = $('#'+gridId).datagrid('getSelected');
		if(!selected){
			window.top.$.messager.alert('提示',"请选择相关数据进行操作！");
			return;
		}
		window.top.$.messager.confirm('系统提示', '<br>&nbsp;&nbsp;&nbsp;&nbsp;你确定要删除该信息?', function(r) {
			if (r) {
				$.post("delDoc.do", { "docid": selected.docid},
				   function(data){
				   	$('#'+gridId).datagrid('reload'); 
				   	top.messagershow(data);
				   	
				});
			}
		});
	}
	function shenheDoc(id,result){
		if(result == 0){
			result = 1;
		}else{
			result = 0;
		}
		$.post("shenheDoc.do", 
			{ "docid": id,"result":"zt="+result},
		   	function(data){
		   		$('#docgrid').datagrid('reload'); 
		   		top.messagershow(data);
		});
	}
	function restore(gridId){
		$('#'+gridId+'toolbar input').val('');
		$('#'+gridId).datagrid('reload');
	}
	function dosearch(gridId){
		var params =$('#'+gridId).datagrid('options').queryParams;
		if($('#'+gridId+'name').val()){
			params['name'] = '%'+$('#'+gridId+'name').val()+'%';
		}
		if(gridId!='mydocgrid'){
			if($('#'+gridId+'userid').combobox('getValue')){
				params['userid'] = $('#'+gridId+'userid').combobox('getValue');
			}
		}
		$('#'+gridId).datagrid('reload',params);
	}
</script>

</head>
<body>
<div class="easyui-tabs" data-options="fit:true">
	<div title="我的文档" data-options="iconCls:'icon-users'">
		<table id="mydocgrid" data-options="fit:true,border:false"></table>
	</div>
	<div title="部门文档" data-options="iconCls:'icon-role',closable:true" >   
       <table id="orgdocgrid" data-options="fit:true,border:false"></table>
    </div>
    <div title="公司文档" data-options="iconCls:'icon-role',closable:true" >   
       <table id="alldocgrid" data-options="fit:true,border:false"></table>
    </div>    
</div>   
	<div id="mydocgridtoolbar" style="display: none;">
		<table border="0" cellpadding="0" cellspacing="0">
			<tr >
				<td valign="center">
					&nbsp;&nbsp;文档名:
					<input  type="text" id="mydocgridname" name="name" maxlength="30" style="width:150px;">
				</td>
				<td valign="center">	
					<a href="javascript:void(0);" class="easyui-linkbutton" data-options="iconCls:'icon-search',plain:true" onclick="dosearch('mydocgrid');">搜索</a>
				</td>
				<td valign="center">
					<div class="datagrid-btn-separator"></div>
				</td>
				<td valign="center">
					<a href="javascript:void(0);" class="easyui-linkbutton" data-options="iconCls:'icon-reload',plain:true" onclick="restore('mydocgrid');">重置</a>
				</td>
				<td valign="center">
					<div class="datagrid-btn-separator"></div>
				</td>
				<td valign="center" align="left">
					<a href="javascript:void(0);" class="easyui-linkbutton" data-options="iconCls:'icon-add',plain:true" onclick="addDoc('mydocgrid');">增加</a>
				</td>
				<td valign="center" align="left">
					<a href="javascript:void(0);" class="easyui-linkbutton" data-options="iconCls:'icon-edit',plain:true" onclick="editDoc('mydocgrid')">修改</a>
				</td>
				<td valign="center" align="left">
					<a href="javascript:void(0);" class="easyui-linkbutton" data-options="iconCls:'icon-cancel',plain:true" onclick="delDoc('mydocgrid')">删除</a>
				</td>
				<td valign="center">
					<div class="datagrid-btn-separator"></div>
				</td>
			</tr>
		</table>
	</div>
	<div id="orgdocgridtoolbar" style="display: none;">
		<table border="0" cellpadding="0" cellspacing="0">
			<tr >
				<td valign="center">
					&nbsp;&nbsp;文档名:
					<input  type="text" id="orgdocgridname" name="name" maxlength="30" style="width:150px;">
				</td>
				<td valign="center">
					&nbsp;&nbsp;上传人 :
					<input id="orgdocgriduserid" class="easyui-combobox"  style="width:100px;" panelHeight:"auto" data-options="valueField:'userid',textField:'username',url:'${request.contextPath}/xadmin/system/listUserForCombox.do'" />
				</td>
				<td valign="center">	
					<a href="javascript:void(0);" class="easyui-linkbutton" data-options="iconCls:'icon-search',plain:true" onclick="dosearch('orgdocgrid');">搜索</a>
				</td>
				<td valign="center">
					<div class="datagrid-btn-separator"></div>
				</td>
				<td valign="center">
					<a href="javascript:void(0);" class="easyui-linkbutton" data-options="iconCls:'icon-reload',plain:true" onclick="restore('orgdocgrid');">重置</a>
				</td>
				<td valign="center">
					<div class="datagrid-btn-separator"></div>
				</td>
				<td valign="center" align="left">
					<a href="javascript:void(0);" class="easyui-linkbutton" data-options="iconCls:'icon-add',plain:true" onclick="addDoc('orgdocgrid');">增加</a>
				</td>
				<td valign="center">
					<div class="datagrid-btn-separator"></div>
				</td>
			</tr>
		</table>
	</div>
	<div id="alldocgridtoolbar" style="display: none;">
		<table border="0" cellpadding="0" cellspacing="0">
			<tr >
				<td valign="center">
					&nbsp;&nbsp;文档名:
					<input  type="text" id="alldocgridname" name="name" maxlength="30" style="width:150px;">
				</td>
				<td valign="center">
					&nbsp;&nbsp;上传人 :
					<input id="alldocgriduserid" class="easyui-combobox"  style="width:100px;" panelHeight:"auto" data-options="valueField:'userid',textField:'username',url:'${request.contextPath}/xadmin/system/listUserForCombox.do'" />
				</td>
				<td valign="center">	
					<a href="javascript:void(0);" class="easyui-linkbutton" data-options="iconCls:'icon-search',plain:true" onclick="dosearch('alldocgrid');">搜索</a>
				</td>
				<td valign="center">
					<div class="datagrid-btn-separator"></div>
				</td>
				<td valign="center">
					<a href="javascript:void(0);" class="easyui-linkbutton" data-options="iconCls:'icon-reload',plain:true" onclick="restore('alldocgrid');">重置</a>
				</td>
				<td valign="center">
					<div class="datagrid-btn-separator"></div>
				</td>
				<td valign="center" align="left">
					<a href="javascript:void(0);" class="easyui-linkbutton" data-options="iconCls:'icon-add',plain:true" onclick="addDoc('alldocgrid');">增加</a>
				</td>
				<td valign="center">
					<div class="datagrid-btn-separator"></div>
				</td>
			</tr>
		</table>
	</div>
</body>
</html>